package kr.co.sharping.Activity;

import java.util.ArrayList;

import kr.co.sharping.R;
import kr.co.sharping.CustomView.NonSwipeableViewPager;
import kr.co.sharping.Fragment.f_signup_step1;
import kr.co.sharping.Fragment.f_signup_step2;
import kr.co.sharping.Fragment.f_signup_step3;
import kr.co.sharping.PageAdapter.Adapter_SignupPage;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;

import com.viewpagerindicator.CirclePageIndicator;

public class a_signup extends BaseActionbarActivity {

	private CirclePageIndicator indicator;
	private NonSwipeableViewPager pager;
	private Button before, next;
	
	private ArrayList<Fragment> list;
	
	private int visit_page = 0;

	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.a_signup);

		setViewMapping();
		setViewPager();
		setEvent();
	}

	private void setViewMapping() {
		indicator = (CirclePageIndicator) findViewById(R.id.a_signup_pagerindicator);
		pager = (NonSwipeableViewPager) findViewById(R.id.a_signup_viewpager);
		before = (Button) findViewById(R.id.a_signup_button_before);
		next = (Button) findViewById(R.id.a_signup_button_next);
		
		indicator.setFillColor(0xfff76262);
		indicator.setStrokeColor(0xfff76262);
		indicator.setRadius(8);
		// indicator.set
	}

	private void setViewPager() {
		
		list = new ArrayList<Fragment>();
		list.add(new f_signup_step1());
		list.add(new f_signup_step2());
		list.add(new f_signup_step3());
		
		Adapter_SignupPage adapter = new Adapter_SignupPage(getSupportFragmentManager(), list);
		pager.setAdapter(adapter);
		
		indicator.setViewPager(pager);
	}

	private void setEvent() {
		before.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				
				if (visit_page == 0) {
					return;
				}
				visit_page = visit_page - 1;
				pager.setCurrentItem(visit_page, true);
			}
		});
		
		next.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				
				if (visit_page == 2) {
					return;
				}
				
				visit_page = visit_page + 1; 
				pager.setCurrentItem(visit_page, true);
			}
		});
	}
}
